package com.jltx.xq.videoeditorlearnpro.utils;

import android.content.Context;
import android.util.DisplayMetrics;
import android.view.WindowManager;

import com.jltx.xq.videoeditorlearnpro.App;

/**
 * @author jltxseo
 *         Created by junlintianxia on 2018/03/07.
 * @version V1.0
 * @Description
 */

public class Utils {

    public static int mWidth = -1;
    public static int mHeight = -1;

    public static void init() {
        WindowManager mWindowManager = (WindowManager) App.getApp().getSystemService(Context.WINDOW_SERVICE);
        DisplayMetrics metrics = new DisplayMetrics();
        mWindowManager.getDefaultDisplay().getMetrics(metrics);
        //获取到的是px，像素，绝对像素，需要转化为dpi
        int width = metrics.widthPixels;
        int height = metrics.heightPixels;
        mWidth = width < height ? width : height;
        mHeight = width < height ? height : width;
    }


    public static int getScreenWidth() {
        if (mWidth < 0) {
            init();
        }
        return mWidth;
    }


    public static int getScreenHeight() {
        if (mHeight < 0) {
            init();
        }
        return mHeight;
    }


}
